<?php
defined('_XR_EXEC') or die();
/**
 * 静态字典
 */
class list_Model extends Model
{

  /* 得到列表 */
	public function getlist($key){
		$db = factory::getDBO();
		$list_rs = $db->loadassoclist('select * from t_list_'.$key.' where deleted=0 order by show_index ASC ');
		
		return $list_rs;
	}
	 
	
	public function getval($key,$val){
		$db = factory::getDBO();
		$rr = $db->loadresult('select val from t_list_'.$key.' where id="'.$val.'" ');
		if($rr === false){
			$rr = NULL;
		}
		return $rr;
	}
	 
	public function gethtml($key,$val='',$css=''){
		$db = factory::getDBO();
		$rs = $db->loadassoclist('select id,val from t_list_'.$key.' where deleted=0 order by show_index ASC ');
		$html = '<select '.$css.'  >';
		foreach($rs as $v){
			if($v['id'] == $val){
				$html .= '<option value="'.$v['id'].'" selected="selected">'.$v['val'].'</option>';
			}else{
				$html .= '<option value="'.$v['id'].'">'.$v['val'].'</option>';
			}
		}
		$html .= '</select>';
		return $html;
	}
	 
}

?>